<?php
/**
 * View class
 * 
 * @author Mathieu Pheulpin - sokaru91@gmail.com
 *
 */
class Mac_View
{
    /**
     * Path of the view file
     * 
     * @var string
     */
    private $path;
    
    public function __construct ($path)
    {
        $this->path = $path;
    }
    
    public function content ()
    {
        $render_path = $this->path;
        if (is_file($render_path)) {
            ob_start();
            include $render_path;
            $contents = ob_get_contents();
            ob_end_clean();
            return $contents;
        } else {
            throw new Mac_View_Exception_NotFound('Unable to render view script. File not found at '.$render_path);
        }
    }
    
    public function __set ($name, $value)
    {
        $this->$name = $value;
    }
    
    public function __get ($name)
    {
        return null;
    }
}